from sklearn import linear_model,pipeline,preprocessing
import numpy as np
import matplotlib.pyplot as plt

np.random.seed(666)
x = np.linspace(-3,3,100)
x = x.reshape(-1,1)
y = 1.5*x**2 + 3*x -2*x**3 + 2 + np.random.normal(0,1,size=100).reshape(-1,1)

x_train = x
y_train = y

def MultipleLinearRegression(degree):
    return pipeline.Pipeline([
        ('poly',preprocessing.PolynomialFeatures(degree=degree)),
        ('std_scaler',preprocessing.StandardScaler()),
        ('lin_reg',linear_model.LinearRegression())
    ])

model = MultipleLinearRegression(degree=3)

model.fit(x_train,y_train)

f_wb = model.predict(np.sort(x_train,axis=0))

fig,(ax) = plt.subplots(1,1,constrained_layout=True,figsize=(12,8))
ax.set_title('None')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.scatter(x_train,y_train,c='r',label='Actual Values')
ax.plot(np.sort(x_train,axis=0),f_wb,c='b',label='Predictions')
ax.legend()
plt.show()